﻿using System;
using System.Web;

namespace Telerik.Web.Mvc.UI {
    public static class BrowserRegistrarBuilder {
        public static ScriptRegistrarBuilder Browser(this ScriptRegistrarBuilder scriptRegistrar, Action<BrowserCollectionBuilder> configureAction) {
            var registrar = (ScriptRegistrar)scriptRegistrar;

            BrowserCollectionBuilder builder = new BrowserCollectionBuilder(WebAssetType.JavaScript, registrar.Scripts, HttpContext.Current.Request.Browser);

            configureAction(builder);

            return scriptRegistrar;
        }

        public static StyleSheetRegistrarBuilder Browser(this StyleSheetRegistrarBuilder styleSheetRegistrar, Action<BrowserCollectionBuilder> configureAction) {
            var registrar = (StyleSheetRegistrar)styleSheetRegistrar;

            BrowserCollectionBuilder builder = new BrowserCollectionBuilder(WebAssetType.JavaScript, registrar.StyleSheets, HttpContext.Current.Request.Browser);

            configureAction(builder);

            return styleSheetRegistrar;
        }
    }
}